<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Ads/classes/PhpFox_ComponentShowAds.class.php, $Author:  $ */



/** Component for getting random ad
 * @version $Id: PhpFox_ComponentShowAds.class.php 302 2008-02-11 07:14:04Z phpfoxsv $
 * @package module.ads
 *
 */
class PhpFox_Mod_Ads_ComponentShowAds extends BaseComponent
{
    function process()
    {
        $oAdsService = &$this->_oModule->getService('Ads');
        /* @var $oAdsService PhpFox_Mod_Admin_ServiceAds */
        $oSecurityService = &App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */

        if (App::getSetting('turn_on_adds'))
        {
            return '';
        }

        $aMembership = $oSecurityService->getUserMembershipData();
        if ($aMembership['no_ads'])
        {
            return '';
        }

        $iType = $this->_aParams['place'];
        $sTxt = $oAdsService->getRandomAds($iType);
	
        if (App::getParam('ads_ajax') && $sTxt)
        {
        	switch($iType)
        	{
        		case 1:
        			$sWidth = 468;
        			$sHeight = 60;
        			break;
        		case 2:
        			$sWidth = 728;
        			$sHeight = 90;        			
        			break;
        		case 3:
        			$sWidth = 300;
        			$sHeight = 250;        			
        			break;  
        		case 4:
        			$sWidth = 160;
        			$sHeight = 600;        			
        			break;
        		case 5:
        			$sWidth = 336;
        			$sHeight = 280;        			
        			break;        			
        	}
       		$sTxt = '<iframe allowtransparency="true" id="ajax_ad_' . $iType . '" name="ajax_ad_' . $iType . '" width="' . ($sWidth) . '" height="' . ($sHeight) . '" scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe><script type="text/javascript">callAdd("' . $iType . '", "' . App::getParam('ads_ajax_timeout') . '");</script>';
        }
       	return ($sTxt ? $sTxt : '');        
    }
}
?>